import type { RouteConfig } from 'react-router-config';

import { Redirect } from 'react-router-dom';

import loadable from '@loadable/component';
import Home from '@src/pages/home';
import { IconKeys } from '@src/components';

/* eslint-disable import/prefer-default-export */
export const routerConfig: RouteConfig[] = [
  {
    path: '/',
    exact: true,
    meta: { title: '' },
    render: () => <Redirect to="/home" />,
  },
  {
    path: '/home',
    component: Home,
    meta: {
      icon: IconKeys.homeOutlined,
      title: '首页',
      displayOnTree: true,
    },
  },
  {
    path: '/search-table',
    component: loadable(() => import('@src/pages/search-table')),
    meta: {
      icon: IconKeys.tableOutlined,
      title: '通用搜索表格',
      displayOnTree: true,
    },
  },
  {
    path: '/todo',
    component: loadable(() => import('@src/pages/todo')),
    meta: {
      icon: IconKeys.clockCircleOutlined,
      title: 'todo',
      displayOnTree: true,
    },
    routes: [
      {
        path: '/todo/a',
        component: Home,
        meta: {
          icon: IconKeys.clockCircleOutlined,
          title: 'todo-a',
          displayOnTree: true,
        },
      },
    ],
  },
];
